<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			<!-- 一般情况下写法 -->
			<h1>{{firstname+lastname}}</h1>
              <!-- 计算属性 -->
			<h1>{{fullname}}</h1>
			<!-- 逆序显示1个单词 -->
			<h1>{{word.split("").reverse().join("")}}</h1>
			<h1>{{reverseWord}}</h1>
			<h1>循环偶数年龄</h1>
			<ul>
				<li v-for="item,index in oddStudents">
					<h3>{{item.studentName}}</h3>
					<h4>{{item.age}}</h4>
					</li>
			</ul>
		</div>
		<script type="text/javascript">
			var app=new Vue({
				el:"#app",
				data:{
					firstname:"张",
					lastname:"三",
					word:"music",
					students:[
						{
						studentName:"张三",age:16,school:"12",
						imageHeader:"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=944544401,1288717384&fm=11&gp=0.jpg"
					},
					{
						studentName:"李四",age:17,school:"13"
					},
					{
						studentName:"王二",age:18,school:"15"
					},
					{
						studentName:"王一",age:19,school:"15"
					}
					],
				},
				computed:{
					fullname:function(){
						// 会将计算的结果进行缓存,只要this.firstname和this.lastname变量的内容不改变.就不会重新计算
						return this.firstname+this.lastname
					},
					reverseWord:function(){
						return this.word.split("").reverse().join("");
					},
					oddStudents:function(){
					  let results=	this.students.filter((item,i)=>{
							return item.age%2==0
						})
						return results
					}
				}
			})
		</script>
	</body>
</html>
